package com.wx.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wx.serviceImpl.OrderServiseIml;

/**
 * Servlet implementation class ManageOrderServlet
 */
@WebServlet("/servlet/ManageOrderServlet")
public class ManageOrderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ManageOrderServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		OrderServiseIml orderServiseIml= new OrderServiseIml();
		int orderid = Integer.parseInt(request.getParameter("orderid"));
		try {
			boolean b = orderServiseIml.manageOrderById(orderid);
			if(b){
				request.setAttribute("win", "订单已处理");
				request.getRequestDispatcher("../manage/orders/order.jsp").forward(request, response);
			}else{
				request.setAttribute("failed", "订单处理出现异常");
				request.getRequestDispatcher("../manage/orders/order.jsp").forward(request, response);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
